package com.itheima.demo;

import com.itheima.config.SpringConfig;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import javax.sql.DataSource;
import java.sql.Connection;

public class Demo {
    @Test
    public void test1() throws Exception {
        //通过核心配置类的方式创建IOC容器
        ApplicationContext ac = new AnnotationConfigApplicationContext(SpringConfig.class);
        //通过IOC容器调用数据源类
        DataSource ds = ac.getBean(DataSource.class);
        Connection connection = ds.getConnection();
        System.out.println(connection);
    }
}
